class Solution {
public:
    int maxConsecutiveAnswers(string answerKey, int k) {
        int hash[128]={0},ans=0;
        for(int left=0,right=0;right<answerKey.size();++right)
        {
            ++hash[answerKey[right]];
            while(left<right&&hash['T']>k&&hash['F']>k)
                --hash[answerKey[left++]];
            ans=max(ans,right-left+1);
        }
        return ans;
    }
};